﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GalaSoft.MvvmLight;
using RA.Services;
using System.Windows.Input;
using GalaSoft.MvvmLight.Command;
using GalaSoft.MvvmLight.Messaging;
using RA.UI.Messages;
using System.Drawing;
using RA.Common;

namespace RA.UI.ViewModel
{
    public class TemplatesItemViewModel : ViewModelBase
    {
        Template _template;

        public TemplatesItemViewModel(Template template)
        {
            _template = template;
        }

        public Action<TemplatesItemViewModel> AddToSelectedAction
        {
            get;
            set;
        }
        public Action<TemplatesItemViewModel> RemoveFromSelectedAction
        {
            get;
            set;
        }

        public string Name
        {
            get { return _template.DisplayName; }
        }

        public Template Template
        {
            get { return _template; }
        }

        ICommand _findTemplateCommand;
        public ICommand FindTemplateCommand
        {
            get 
            { 
                if(_findTemplateCommand == null)
                    _findTemplateCommand = new RelayCommand(() =>
                        Messenger.Default.Send(new ShowTemplateRectangleMessage
                            (_template))); //TODO

                return _findTemplateCommand;
            }
        }

        ICommand _addCommand;
        public ICommand AddCommand
        {
            get
            {
                if (_addCommand == null)
                    _addCommand = new RelayCommand(() => AddToSelectedAction(this), () => AddToSelectedAction != null); //TODO

                return _addCommand;
            }
        }

        ICommand _removeCommand;
        public ICommand RemoveCommand
        {
            get
            {
                if (_removeCommand == null)
                    _removeCommand = new RelayCommand(() => RemoveFromSelectedAction(this), () => RemoveFromSelectedAction != null); //TODO

                return _removeCommand;
            }
        }


    }
}
